﻿<Window x:Class="Microsoft.Pfe.Xrm.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converter="clr-namespace:Microsoft.Pfe.Xrm.Converter"
        Title="Dynamics CRM Mobile SDK Tools" Height="200" Width="700"
        SizeToContent="Height"
        WindowStyle="None"
        WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary>
            <converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
            <SolidColorBrush x:Key="MAIN_COLOR" Color="#002050"/>            
            <Style TargetType="TextBlock">
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="Margin" Value="0,4,10,4"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>            
            <Style TargetType="Button">
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="Margin" Value="0,4"/>
                <Setter Property="Foreground" Value="White"/>
                <Setter Property="Background" Value="{StaticResource MAIN_COLOR}"/>
                <Setter Property="BorderThickness" Value="0"/>
            </Style>           
        </ResourceDictionary>
    </Window.Resources>
    <Grid x:Name="myGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Background="{StaticResource MAIN_COLOR}" >
            <StackPanel VerticalAlignment="Center" Margin="20,0">
                <TextBlock Text="Linq Pad Driver for Dynamics CRM" Foreground="White" FontSize="24" />
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1" Margin="20,10,20,0" IsEnabled="{Binding !IsLoaded}" Visibility="{Binding IsNewConnection, Converter={StaticResource BoolToVisibilityConverter}}">
            <Button Content="Login to CRM" HorizontalAlignment="Left" Width="150" Command="{Binding LoginCommand}"/>
        </Grid>
        <Grid Grid.Row="1" Margin="20,10,20,0" Visibility="{Binding IsNewConnection, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=true}">
            <Button Content="Change Credential" HorizontalAlignment="Left" Width="150" Command="{Binding ChangeCredentialCommand}"/>
        </Grid>
        <Grid Grid.Row="2" Margin="20,10,20,0" Visibility="{Binding IsNewConnection, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=true}">
            <Button Content="Reload Data" HorizontalAlignment="Left" Width="150" Command="{Binding ReloadCommand}" />            
        </Grid>
        <Grid Grid.Row="3" Margin="20,10,20,0" Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=true}">
            <Button HorizontalAlignment="Left" Width="150" Click="Button_Click">Exit</Button>
        </Grid>
        <Grid Grid.Row="4">
            <Label Content="{Binding Message}"/>
        </Grid>
        <Grid Grid.RowSpan="5" Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibilityConverter}}"  
              Height="200" Width="700" Opacity=".9" Background="Gray">
            <Grid VerticalAlignment="Center" Margin="150,0" >
                <ProgressBar IsIndeterminate="{Binding IsLoading,Mode=TwoWay}" 
                     Height="32" Foreground="{StaticResource MAIN_COLOR}"/>
                <TextBlock Text="{Binding LoadMessage}" Foreground="{StaticResource MAIN_COLOR}" FontSize="20" Margin="30,0"/>
            </Grid>
        </Grid>
    </Grid>
</Window>
